package com.kkb.controller;

import com.kkb.pojo.Account;
import com.kkb.service.AccountService;
import lombok.experimental.Wither;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("account")//这个是前端请求/account/findAll.do里的account
public class AccountController {
    @Autowired
    private AccountService accountService;
    @RequestMapping("findAll")//这个是前端请求/account/findAll.do里的findAll
    public List<Account> findAll(){
        return accountService.findAll();
    }
    @RequestMapping("save")
    public List<Account> save(@RequestBody Account account){
        accountService.save(account);
        return this.findAll();
    }
    @RequestMapping("delete")
    public String delete(Integer id){
        accountService.deleteById(id);
        return "delete success";
    }
    @RequestMapping("update")
    public String update(@RequestBody Account account){
        accountService.update(account);
        return "update success";
    }



}
